/**
 * inputRef    ref对象链       必传
 * value       初始值          选传
 */
import React, { MutableRefObject, useState } from 'react';
import './index.less';

interface InputProps {
  inputRef: MutableRefObject<any>;
  value?: any;
}
function InputCom(props: InputProps) {
  console.log('Input props:', props);
  const { inputRef, value } = props;
  const [inputValue, setInputvalue] = useState(value || '');
  function change() {
    console.log('inputRef===>', inputRef.current.value);
    setInputvalue(inputRef.current.value);
  }
  return (
    <div className='input-com'>
      <input type='text' ref={inputRef} value={inputValue} onChange={change} />
    </div>
  );
}
export default InputCom;
